import java.security.SecureRandom;


/**
 * Created by Dominik on 2014-10-17.
 * poprawki
 */
public class Deck {

    public static final int DECK_SIZE = 52;

    private int[] deck = new int[DECK_SIZE];
    private int cardLeft = DECK_SIZE;

    public void printDeck () {
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 13; j++) {
                System.out.print(deck[i*13+j] + " ");
            }
            System.out.print("\n");
        }
    }

    SecureRandom Generator = new SecureRandom();

    public void shuffle() {
        for(int i = 0; i < DECK_SIZE; i++) {
            if(deck[i] == -1) {
                deck[i] = 0;
                cardLeft++;
            }
        }
    }
    public int giveCard(int player) {
        if(cardLeft == 0)
            shuffle();
        int candidate = Generator.nextInt(DECK_SIZE);
        while(deck[candidate] != 0) {
            candidate = Generator.nextInt(DECK_SIZE);
        }
        deck[candidate] = player;
        cardLeft--;
        return candidate;
    }

    public void returnCardToDeck(int card) {
    	System.out.println("deck[card]"+ deck[card]);
        deck[card] = -1;
        System.out.println("card"+card);
    }



}